// This MFC Samples source code demonstrates using MFC Microsoft Office Fluent User Interface 
// (the "Fluent UI") and is provided only as referential material to supplement the 
// Microsoft Foundation Classes Reference and related electronic documentation 
// included with the MFC C++ library software.  
// License terms to copy, use or distribute the Fluent UI are available separately.  
// To learn more about our Fluent UI licensing program, please visit 
// http://msdn.microsoft.com/officeui.
//
// Copyright (C) Microsoft Corporation
// All rights reserved.

// MainFrm.h : interface of the CMainFrame class
//

#pragma once
#include "MessageListPane.h"
#include "FolderTreeCtrl.h"
#include "NavigationBar.h"
#include "MyRibbonBar.h"
#include "MyStatusBar.h"
#include "Resource.h"

class CMessageDoc;

class CMainFrame : public CMDIFrameWndEx
{
	DECLARE_DYNAMIC(CMainFrame)
public:
	CMainFrame();
private:
	int								m_sort;
	int								m_listPosition;

public:
	virtual BOOL PreCreateWindow(CREATESTRUCT& cs);

	virtual ~CMainFrame();

#ifdef _DEBUG
	virtual void AssertValid() const;
	virtual void Dump(CDumpContext& dc) const;
#endif

public:
	CMyRibbonBar					m_wndRibbonBar;
	CMyStatusBar					m_wndStatusBar;
	CMessageListPane				m_wndMessageListPane;
	CNavigationBar					m_wndNavigationBar;
	CMFCCaptionBar					m_wndCaptionBar;
protected:
	BOOL CreateDockingWindows();
	void SetDockingWindowIcons();
	BOOL CreateNavigationBar();
	BOOL CreateCaptionBar();
	
	int FindFocusedOutlookWnd(CMFCOutlookBarTabCtrl** ppOutlookWnd);

	CMFCOutlookBarTabCtrl* FindOutlookParent(CWnd* pWnd);
	CMFCOutlookBarTabCtrl* m_pCurrOutlookWnd;
	CMFCOutlookBarPane*    m_pCurrOutlookPage;
public:
	CMessageListPane * GetMessageListPane(void);
	CMFCRibbonBar *GetRibbonBar(void);
	void RefreshMessageList();
	void UpdateApplicationSettings();
	void RefreshTaskInfo();
	void RefreshFolderTree(BOOL recreate);
	CMessageDoc * GetDefaultDocument(BOOL createNew = TRUE);
	void SetDefaultDocument(CMessageDoc *pDoc);
private:
	CMessageDoc * m_pDefaultDoc;
	gcroot <KingOfCSharp::iHunter::UI::TaskListWindow ^> m_frmTaskList;
protected:
	// Generated message map functions
	afx_msg void OnFoldersMarkAllAsRead();
	//{{AFX_MSG(CMainFrame)
	afx_msg int OnCreate(LPCREATESTRUCT lpCreateStruct);
	afx_msg void OnWindowManager();
	afx_msg void OnViewCaptionBar();
	afx_msg void OnUpdateViewCaptionBar(CCmdUI* pCmdUI);
	//Sorting
	afx_msg void OnSortByTitle();
	afx_msg void OnSortByPublishTime();
	afx_msg void OnSortByAuthor();

	afx_msg void OnUpdateSortByTitle(CCmdUI *pCmdUI);
	afx_msg void OnUpdateSortByAuthor(CCmdUI *pCmdUI);
	afx_msg void OnUpdateSortByPublishTime(CCmdUI *pCmdUI);

	//List position
	afx_msg void OnPositoinLeft();
	afx_msg void OnPositionTop();

	afx_msg void OnUpdatePositoinLeft(CCmdUI *pCmdUI);
	afx_msg void OnUpdatePositionTop(CCmdUI *pCmdUI);

	afx_msg void OnTasksShowTasks();
	//}}AFX_MSG
	afx_msg void OnMessagesMarkAsRead();
	afx_msg void OnMessagesMardAsUnread();

	afx_msg void OnMessagesNew();
	afx_msg void OnFoldersCreate();
	afx_msg void OnFoldersRename();
	afx_msg void OnFoldersMove();

	afx_msg void OnFoldersDelete();
	afx_msg void OnFoldersSettings();
	afx_msg void OnSyncronizeAll();
	afx_msg void OnSyncronizeFolder();
	afx_msg void OnSyncronizeItem();
	afx_msg void OnMessagesMove();
	afx_msg void OnMessagesCopy();
	afx_msg void OnMessagesApplyFilters();
	afx_msg void OnFoldersApplyFiltersToAll();
	afx_msg void OnMessagesMarkAsSpam();
	afx_msg void OnMessagesMarkAsNonspam();
	afx_msg void OnViewRefresh();
	afx_msg void OnMessagesDelete();


	afx_msg void OnUpdateUITaskButton(CCmdUI *);


	afx_msg void OnUpdateUIFoldersCreate(CCmdUI *);
	afx_msg void OnUpdateUIFoldersRename(CCmdUI *);
	afx_msg void OnUpdateUIFoldersMove(CCmdUI *);
	afx_msg void OnUpdateUIFoldersDelete(CCmdUI *);
	afx_msg void OnUpdateUIFoldersSettings(CCmdUI *);
	afx_msg void OnUpdateUISyncronizeFolder(CCmdUI *);
	afx_msg void OnUpdateUISyncronizeItem(CCmdUI *);
	afx_msg void OnUpdateUIMessagesApplyFilters(CCmdUI *);
	afx_msg void OnUpdateUIFoldersApplyFiltersToAll(CCmdUI *);
	afx_msg void OnUpdateUIMessagesMarkAsSpam(CCmdUI *);
	afx_msg void OnUpdateUIMessagesMarkAsNonspam(CCmdUI *);
	afx_msg void OnUpdateUIMessagesMarkAsRead(CCmdUI *pCmdUI);
	afx_msg	void OnUpdateUIMessagesMarkAsUnread(CCmdUI *pCmdUI);
	afx_msg	void OnUpdateUIFoldersMarkAllAsUnead(CCmdUI *pCmdUI);

	afx_msg void OnUpdateUIMessagesMove(CCmdUI *pCmdUI);
	afx_msg void OnUpdateUIMessagesCopy(CCmdUI *pCmdUI);
	afx_msg void OnUpdateUIMessagesDelete(CCmdUI *pCmdUI);



public:
	BEGIN_DELEGATE_MAP(CMainFrame)
		EVENT_DELEGATE_ENTRY(OnTaskComplete, System::Object^, KingOfCSharp::iHunter::UI::TaskCompleteEventArgs ^)
	END_DELEGATE_MAP()
	void OnTaskComplete(System::Object ^sender, KingOfCSharp::iHunter::UI::TaskCompleteEventArgs ^e);
private:
	CRITICAL_SECTION m_csUpdateUI;
	BOOL m_bSearchUnreadOnly;

public:
	DECLARE_MESSAGE_MAP()
	afx_msg void OnTimer(UINT_PTR nIDEvent);

	afx_msg void OnFoldersClear();
	afx_msg void OnUpdateFoldersClear(CCmdUI *pCmdUI);
	afx_msg void OnSearchTitle();
	afx_msg void OnSearchAuthor();
	afx_msg void OnSearchMatchexactly();
	afx_msg void OnSearchUnreadonly();
	afx_msg void OnSearchSearch();
	afx_msg void OnUpdateSearchMatchexactly(CCmdUI *pCmdUI);
	afx_msg void OnUpdateSearchUnreadonly(CCmdUI *pCmdUI);
	afx_msg void OnSynchronizeDownloadattachments();
	afx_msg void OnUpdateSynchronizeDownloadattachments(CCmdUI *pCmdUI);
	afx_msg void OnViewOpeninnewtab();
};


